﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CommunitySystem.DataService;
using CommunitySystem.Assert;
using CommunitySystem.PageView.SystemManager;
using CommunitySystem.Views;

namespace CommunitySystem.Map
{
    public partial class HomeMap : UserControl, IAsyncCtrl
    {

        private DataService.DataServiceClient client = null;
        public string Title
        {
            get { return ""; }
            set { Title = value; }
        }
        #region 实现IAsyncCtrl
        public NavMoveSwitch Nav { get; set; }
        public bool PageLoaded
        {
            get;
            set;
        }
        private int _pid = 0;
        #endregion
        private BusyIndicator _busyIndicator;
        
        public HomeMap(int pid, BusyIndicator busyIndicator)
        {
            InitializeComponent();
            _pid = pid;
            _busyIndicator = busyIndicator;
            client = new DataService.DataServiceClient();
            LoadMenuDynamic lm = new LoadMenuDynamic(tabControl1);
            lm.LoadMenu(client, _pid, myTree);
            //App.currentTabControl = tabControl1;
            //client.GetMenuByPIDAsync(pid);
            //client.GetMenuByPIDCompleted += new EventHandler<DataService.GetMenuByPIDCompletedEventArgs>(client_GetMenuByPIDCompleted);
        }


        public void RemoveTabItem()
        {
            tabControl1.Items.Remove(tabControl1.SelectedItem);
        }


        /// <summary>
        /// 每次如果有相同的tabid， 则不新增tab页，
        /// </summary>
        /// <param name="uc"></param>
        /// <param name="header"></param>
        /// <param name="tabid"></param>
        void AddTabItem(UserControl uc, string header, string tabid, TabControl Control)
        {
            CommunitySystem.Infrastructure.CommonMethod.TabControlMethod.addNewTabItem(uc, header, tabid, Control, App.Current.Resources["tabItemStyle"] as Style);

        }
    }
}
